<template>
  <el-dialog
    v-el-drag-dialog
    title="详情"
    :close-on-click-modal="false"
    :modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="60px" v-if="this.dataForm.type == 1">
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="是否支付:" label-width="160px">
            <span v-if="dataForm.isPay == 0">未支付</span>
            <span v-else-if="dataForm.isPay == 1">已支付</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="支付订单号:" label-width="160px">
            <span>{{dataForm.payNo}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="支付金额:" label-width="160px">
            <span>{{dataForm.payMoney}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="支付现金券:" label-width="160px">
            <span>{{dataForm.payIntegral}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="优惠金额:" label-width="160px">
            <span>{{dataForm.preferentialMoney}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="支付类型:" label-width="160px">
            <span v-if="dataForm.payType == 0">扫码</span>
            <span v-if="dataForm.payType == 1">买单</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="是否返券:" label-width="160px">
            <span v-if="dataForm.isCommission == 0">不返券</span>
            <span v-if="dataForm.isCommission == 1">返券</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="赠送现金券数量:" label-width="160px">
            <span>{{dataForm.givingIntegral}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="支付备注:" label-width="160px">
            <span>{{dataForm.payMessage}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="买家名称:" label-width="160px">
            <span>{{dataForm.payTrueName}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="买家账号:" label-width="160px">
            <span>{{dataForm.payUserName}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="买家类型:" label-width="160px">
            <span v-if="dataForm.payUserType == 1">区域运营商</span>
            <span v-else-if ="dataForm.payUserType == 2">普通联盟店</span>
            <span v-else-if ="dataForm.payUserType == 3">消费者</span>
            <span v-else-if ="dataForm.payUserType == 4">VIP会员</span>
            <span v-else-if ="dataForm.payUserType == 5">中级版联盟店</span>
            <span v-else-if ="dataForm.payUserType == 6">高级版联盟店</span>
            <span v-else-if ="dataForm.payUserType == 7">城市合伙人</span>
            <span v-else-if ="dataForm.payUserType == 8">城市合伙人联盟店</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="店铺名称:" label-width="160px">
            <span>{{dataForm.trueName}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="店铺账号:" label-width="160px">
            <span>{{dataForm.storeUserName}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="支付方式:" label-width="160px">
            <span v-if="dataForm.payFrom == 0">微信</span>
            <span v-else-if ="dataForm.payFrom == 1">支付宝</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="店铺类型:" label-width="160px">
            <span v-if="dataForm.storeUserType == 1">区域运营商</span>
            <span v-else-if ="dataForm.storeUserType == 2">普通联盟店</span>
            <span v-else-if ="dataForm.storeUserType == 3">消费者</span>
            <span v-else-if ="dataForm.storeUserType == 4">VIP会员</span>
            <span v-else-if ="dataForm.storeUserType == 5">中级版联盟店</span>
            <span v-else-if ="dataForm.storeUserType == 6">高级版联盟店</span>
            <span v-else-if ="dataForm.storeUserType == 7">城市合伙人</span>
            <span v-else-if ="dataForm.storeUserType == 8">城市合伙人联盟店</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="支付来源:" label-width="160px">
            <span v-if="dataForm.paySrc == 0">安卓</span>
            <span v-else-if ="dataForm.paySrc == 1">苹果</span>
            <span v-else-if ="dataForm.paySrc == 2">小程序</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="店铺类型:" label-width="160px">
            <span>{{dataForm.successTime}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="支付返钱金额:" label-width="160px">
            <span>{{dataForm.commission}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="流水号:" label-width="160px">
            <span>{{dataForm.tradeNo}}</span>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="60px" v-if="this.dataForm.type == 2">
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="付费者名称:" label-width="160px">
            <span>{{dataForm.userName}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="推荐者名称:" label-width="160px">
            <span>{{dataForm.recommendUserName}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="订单编号:" label-width="160px">
            <span>{{dataForm.orderNo}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="返佣类型:" label-width="160px">
            <span v-if="dataForm.commissionType == 1">福利订单返佣</span>
            <span v-if="dataForm.commissionType == 2">分享赚</span>
            <span v-if="dataForm.commissionType == 3">推广金额</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="佣金获得金额:" label-width="160px">
            <span>{{dataForm.commissionMoney}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="获得购买者用户的佣金百分比:" label-width="160px">
            <span>{{dataForm.commissionPercent}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="佣金消息备注:" label-width="160px">
            <span>{{dataForm.commissionMessage}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="推荐者用户类型:" label-width="160px">
            <span v-if="dataForm.recommendUserType == 1">区域运营商</span>
            <span v-else-if ="dataForm.recommendUserType == 2">普通联盟店</span>
            <span v-else-if ="dataForm.recommendUserType == 3">消费者</span>
            <span v-else-if ="dataForm.recommendUserType == 4">VIP会员</span>
            <span v-else-if ="dataForm.recommendUserType == 5">中级版联盟店</span>
            <span v-else-if ="dataForm.recommendUserType == 6">高级版联盟店</span>
            <span v-else-if ="dataForm.recommendUserType == 7">城市合伙人</span>
            <span v-else-if ="dataForm.recommendUserType == 8">城市合伙人联盟店</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="商品总利润:" label-width="160px">
            <span>{{dataForm.goodsProfits}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="商品零售价格:" label-width="160px">
            <span>{{dataForm.goodsPrice}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="创建时间:" label-width="160px">
            <span>{{dataForm.createTime}}</span>
          </el-form-item>
        </el-col>
        <!-- <el-col :span="10">
          <el-form-item label="商品零售价格:" label-width="160px">
            <span>{{dataForm.goodsPrice}}</span>
          </el-form-item>
        </el-col> -->
      </el-row>
    </el-form>
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="60px" v-if="this.dataForm.type == 3">
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="商品名:" label-width="160px">
            <span>{{dataForm.goodsName}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="商品描述:" label-width="160px">
            <span>{{dataForm.goodsDesc}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="商家名称:" label-width="160px">
            <span>{{dataForm.trueName}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="商家账号:" label-width="160px">
            <span>{{dataForm.userName}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="商家类型:" label-width="160px">
            <span v-if="dataForm.userType == 1">区域运营商</span>
            <span v-else-if ="dataForm.userType == 2">普通联盟店</span>
            <span v-else-if ="dataForm.userType == 3">消费者</span>
            <span v-else-if ="dataForm.userType == 4">VIP会员</span>
            <span v-else-if ="dataForm.userType == 5">中级版联盟店</span>
            <span v-else-if ="dataForm.userType == 6">高级版联盟店</span>
            <span v-else-if ="dataForm.userType == 7">城市合伙人</span>
            <span v-else-if ="dataForm.userType == 8">城市合伙人联盟店</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="商品市场价格:" label-width="160px">
            <span>{{dataForm.marketPrice}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="会员价格:" label-width="160px">
            <span>{{dataForm.vipPrice}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="商品销售量:" label-width="160px">
            <span>{{dataForm.saleCount}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="上架/下架:" label-width="160px">
            <span v-if="dataForm.isSale == 0">下架</span>
            <span v-if="dataForm.isSale == 1">上架</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="是否反现金券:" label-width="160px">
            <span v-if="dataForm.isCommission == 0">不返现金券</span>
            <span v-if="dataForm.isCommission == 1">返现金券</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="现金券:" label-width="160px">
            <span>{{dataForm.commission}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="审核结果:" label-width="160px">
            <span v-if="dataForm.goodsStatus == 0">待审核</span>
            <span v-if="dataForm.goodsStatus == -1">禁售</span>
            <span v-if="dataForm.goodsStatus == 1">审核通过</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="创建时间:" label-width="160px">
            <span>{{dataForm.createTime}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="上架时间:" label-width="160px">
            <span>{{dataForm.saleTime}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="下架时间:" label-width="160px">
            <span>{{dataForm.shelvesTime}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="审核说明:" label-width="160px">
            <span>{{dataForm.statusRemarks}}</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="商品运费:" label-width="160px">
            <span>{{dataForm.deliverMoney}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="配送方式:" label-width="160px">
            <span v-if="dataForm.distributionTypes == 0">物流</span>
            <span v-if="dataForm.distributionTypes == -1">物流、自取、商家配送</span>
            <span v-if="dataForm.distributionTypes == 1">自取</span>
            <span v-if="dataForm.distributionTypes == 2">商家配送</span>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="10">
          <el-form-item label="商品库存:" label-width="160px">
            <span>{{dataForm.goodsStock}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="点击数量:" label-width="160px">
            <span>{{dataForm.clickCount}}</span>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </el-dialog>
</template>

<script>
  export default {
    data () {
      return {
        visible: false,
        dataForm: {
          type: 0,
          isPay: '',
          payNo: '',
          payMoney: '',
          payIntegral: '',
          preferentialMoney: '',
          payType: '',
          isCommission: '',
          givingIntegral: '',
          payMessage: '',
          payTrueName: '',
          payUserName: '',
          payUserType: '',
          trueName: '',
          storeUserName: '',
          storeUserType: '',
          payFrom: '',
          paySrc: '',
          successTime: '',
          commission: '',
          tradeNo: '',
          userName: '',
          recommendUserName: '',
          orderNo: '',
          commissionType: '',
          commissionMoneyv: '',
          commissionPercent: '',
          commissionMessage: '',
          recommendUserType: '',
          goodsProfits: '',
          goodsPrice: '',
          goodsName: '',
          goodsDesc: '',
          userType: '',
          marketPrice: '',
          vipPrice: '',
          saleCount: '',
          isSale: '',
          goodsStatus: '',
          createTime: '',
          saleTime: '',
          shelvesTime: '',
          statusRemarks: '',
          distributionTypes: '',
          deliverMoney: '',
          goodsStock: '',
          clickCount: ''
        },
        dataRule: {}
      }
    },
    methods: {
      init (id, type) {
        // this.dataForm.withrecordid = id || 0
        this.dataForm.type = type
        this.visible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          // 线下
          if (type === 1) {
            if (id) {
              this.$http({
                url: this.$http.adornUrl(`/user/cashAudit/getDetailsOfEarningsAndUnderTheLineById/${id}`),
                method: 'get',
                params: this.$http.adornParams()
              }).then(({data}) => {
                if (data && data.code === 0) {
                  this.dataForm.isPay = data.data.isPay
                  this.dataForm.payNo = data.data.payNo
                  this.dataForm.payMoney = data.data.payMoney
                  this.dataForm.payIntegral = data.data.payIntegral
                  this.dataForm.preferentialMoney = data.data.preferentialMoney
                  this.dataForm.payType = data.data.payType
                  this.dataForm.isCommission = data.data.isCommission
                  this.dataForm.givingIntegral = data.data.givingIntegral
                  this.dataForm.payMessage = data.data.payMessage
                  this.dataForm.payTrueName = data.data.payTrueName
                  this.dataForm.payUserName = data.data.payUserName
                  this.dataForm.payUserType = data.data.payUserType
                  this.dataForm.trueName = data.data.trueName
                  this.dataForm.storeUserName = data.data.storeUserName
                  this.dataForm.storeUserType = data.data.storeUserType
                  this.dataForm.payFrom = data.data.payFrom
                  this.dataForm.paySrc = data.data.paySrc
                  this.dataForm.successTime = data.data.successTime
                  this.dataForm.commission = data.data.commission
                  this.dataForm.tradeNo = data.data.tradeNo
                }
              })
            }
          }
          // 推广
          if (type === 2) {
            if (id) {
              this.$http({
                url: this.$http.adornUrl(`/user/cashAudit/getDetailsOfEarningsAndExtensionById/${id}`),
                method: 'get',
                params: this.$http.adornParams()
              }).then(({data}) => {
                if (data && data.code === 0) {
                  this.dataForm.userName = data.data.userName
                  this.dataForm.recommendUserName = data.data.recommendUserName
                  this.dataForm.orderNo = data.data.orderNo
                  this.dataForm.commissionType = data.data.commissionType
                  this.dataForm.commissionMoney = data.data.commissionMoney
                  this.dataForm.commissionPercent = data.data.commissionPercent
                  this.dataForm.commissionMessage = data.data.commissionMessage
                  this.dataForm.recommendUserType = data.data.recommendUserType
                  this.dataForm.goodsProfits = data.data.goodsProfits
                  this.dataForm.goodsPrice = data.data.goodsPrice
                  this.dataForm.createTime = data.data.createTime
                }
              })
            }
          }
          // 线上
          if (type === 3) {
            if (id) {
              this.$http({
                url: this.$http.adornUrl(`/user/cashAudit/getDetailsOfEarningsAndOnLineById/${id}`),
                method: 'get',
                params: this.$http.adornParams()
              }).then(({data}) => {
                if (data && data.code === 0) {
                  this.dataForm.goodsName = data.data.goodsName
                  this.dataForm.goodsDesc = data.data.goodsDesc
                  this.dataForm.trueName = data.data.trueName
                  this.dataForm.userName = data.data.userName
                  this.dataForm.userType = data.data.userType
                  this.dataForm.marketPrice = data.data.marketPrice
                  this.dataForm.vipPrice = data.data.vipPrice
                  this.dataForm.saleCount = data.data.saleCount
                  this.dataForm.isSale = data.data.isSale
                  this.dataForm.isCommission = data.data.isCommission
                  this.dataForm.commission = data.data.commission
                  this.dataForm.goodsStatus = data.data.goodsStatus
                  this.dataForm.createTime = data.data.createTime
                  this.dataForm.saleTime = data.data.saleTime
                  this.dataForm.shelvesTime = data.data.shelvesTime
                  this.dataForm.statusRemarks = data.data.statusRemarks
                  this.dataForm.distributionTypes = data.data.distributionTypes
                  this.dataForm.deliverMoney = data.data.deliverMoney
                  this.dataForm.goodsStock = data.data.goodsStock
                  this.dataForm.clickCount = data.data.clickCount
                }
              })
            }
          }
        })
      }
    }
  }
</script>
